import request from '@/config/axios'

// 积分规则 VO
export interface PointRuleVO {
  id: number // 主键ID
  ruleName: string // 规则名称
  ruleCode: string // 规则代码
  changeType: number // 变动类型（0.增加 1.扣除）
  changeValue: number // 积分变动值
  status: number // 状态（0有效 1无效）
}

// 积分规则 API
export const PointRuleApi = {
  // 查询积分规则分页
  getRulePage: async (params: any) => {
    return await request.get({ url: `/point/rule/page`, params })
  },

  // 查询积分规则详情
  getRule: async (id: number) => {
    return await request.get({ url: `/point/rule/getById?id=` + id })
  },


  // 修改时段配置状态
  updateStatus: async (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return request.post({ url: '/point/rule/update-status', data: data })
  },

  // 新增积分规则
  createRule: async (data: PointRuleVO) => {
    return await request.post({ url: `/point/rule/create`, data })
  },

  // 修改积分规则
  updateRule: async (data: PointRuleVO) => {
    return await request.post({ url: `/point/rule/update`, data })
  },

  // 删除积分规则
  deleteRule: async (id: number) => {
    return await request.get({ url: `/point/rule/delete?id=` + id })
  },

  // 导出积分规则 Excel
  exportRule: async (params) => {
    return await request.download({ url: `/point/rule/export-excel`, params })
  }
}